package com.example.heimashop.view.activity;

import android.content.Intent;

import com.example.heimashop.base.BaseActivity;
import com.example.heimashop.databinding.ActivitySettingsBinding;
import com.example.heimashop.utils.SPUtils;
import com.example.heimashop.utils.ToastUtils;

/**
 * 设置页面
 * 页面14: SettingsActivity - 设置页面
 */
public class SettingsActivity extends BaseActivity<ActivitySettingsBinding> {

    @Override
    protected ActivitySettingsBinding getViewBinding() {
        return ActivitySettingsBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void initView() {
        // 不需要初始化视图
    }

    @Override
    protected void initData() {
        // 不需要初始化数据
    }

    @Override
    protected void initListener() {
        // 返回按钮
        binding.ivBack.setOnClickListener(v -> finish());

        // 清除缓存
        binding.llClearCache.setOnClickListener(v -> {
            ToastUtils.showShort(this, "缓存已清除");
        });

        // 关于我们
        binding.llAbout.setOnClickListener(v -> {
            ToastUtils.showShort(this, "黑马商城 v1.0.0");
        });

        // 退出登录
        binding.btnLogout.setOnClickListener(v -> {
            SPUtils.putBoolean("isLogin", false);
            SPUtils.remove("username");
            ToastUtils.showShort(this, "已退出登录");
            finish();
        });
    }
}
